package net.qmgyl.demos.shardingjdbc.domain.shared;

import lombok.Data;

import java.util.Collections;
import java.util.List;

/**
 * @author xzw
 * @date ${date}  mailto 741342093@qq.com
 */
@Data
public class Page<T> {

    private List<T> records;
    private Integer pageNum;
    private Integer pageSize;
    private Integer totalCount;

    public static <T> Page<T> create(Integer pageNum, Integer pageSize, List<T> records, Integer totalCount) {
        Page<T> page = new Page<>();
        page.setPageNum(pageNum);
        page.setPageSize(pageSize);
        page.setRecords(records);
        page.setTotalCount(totalCount);
        return page;
    }

    public static <T> Page<T> empty(Integer pageNum, Integer pageSize) {
        return create(pageNum, pageSize, Collections.<T>emptyList(), 0);
    }
}
